package com.rt.tmpt.controller.springmvc.admin;


import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import springfox.documentation.annotations.ApiIgnore;

import java.util.HashMap;
import java.util.Map;

@ApiIgnore
@Controller
@RequestMapping("/admin123/olap")
@Slf4j
public class OlapAction {

    private static final long serialVersionUID = 1L;

    private String pageTitle;
    private String pageName;
    private String schemaFilename;
    private String mdx;

    private String result;

    public String genQueryPageAction() {
        try {
            System.out.println(pageTitle);
            System.out.println(pageName);
            System.out.println(schemaFilename);
            System.out.println(mdx);

            Map<String, Object> map = new HashMap<String, Object>();
            map.put("pageTitle", pageTitle);
            map.put("schemaFilename", schemaFilename);
            map.put("mdx", mdx);
            map.put("pageName", pageName);
            genOlapQueryPage(map);
        } catch (Exception e) {
            e.printStackTrace();
            this.result = e.getLocalizedMessage();
        }
        return "input";
    }


    private void genOlapQueryPage(Map map) throws Exception {
        String pageName = map.get("pageName").toString();
        if (pageName.lastIndexOf(".jsp") < 0) {
            pageName += ".jsp";
        }
        //20181127
        String webPath = "";//ServletActionContext.getServletContext().getRealPath("/");
        String pathFtl = webPath + "\\freemarker\\olap\\";
        String pathOut = "/files1/bi/mondrian/";
		/*FreemarkerUtils fmUtils = new FreemarkerUtils(pathFtl,pathOut);
		fmUtils.fprint("query.jsp.ftl", map, pageName);*/
    }


    public String getPageName() {
        return pageName;
    }

    public void setPageName(String pageName) {
        this.pageName = pageName;
    }


    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getPageTitle() {
        return pageTitle;
    }

    public void setPageTitle(String pageTitle) {
        this.pageTitle = pageTitle;
    }

    public String getSchemaFilename() {
        return schemaFilename;
    }

    public void setSchemaFilename(String schemaFilename) {
        this.schemaFilename = schemaFilename;
    }

    public String getMdx() {
        return mdx;
    }

    public void setMdx(String mdx) {
        this.mdx = mdx;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

}
